package com.projecthost.boots.model;

import java.io.Serializable;

public class Product implements Serializable {

    private static final long serialVersionUID = -2636130782490807627L;

    private final String productUrl;
    private final String productName;
    private final Float rating;
    private final String imageUrl;

    public Product(String productUrl, String productName, Float rating, String imageUrl) {
        this.productUrl = productUrl;
        this.productName = productName;
        this.rating = rating;
        this.imageUrl = imageUrl;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((productName == null) ? 0 : productName.hashCode());
        result = prime * result + ((productUrl == null) ? 0 : productUrl.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        Product other = (Product) obj;
        if (productName == null) {
            if (other.productName != null) {
                return false;
            }
        } else if (!productName.equals(other.productName)) {
            return false;
        }
        if (productUrl == null) {
            if (other.productUrl != null) {
                return false;
            }
        } else if (!productUrl.equals(other.productUrl)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("Product [productUrl=");
        builder.append(productUrl);
        builder.append(", productName=");
        builder.append(productName);
        builder.append(", rating=");
        builder.append(rating);
        builder.append(", imageUrl=");
        builder.append(imageUrl);
        builder.append("]");
        return builder.toString();
    }

    public String getProductUrl() {
        return productUrl;
    }

    public String getProductName() {
        return productName;
    }

    public Float getRating() {
        return rating;
    }

    public String getImageUrl() {
        return imageUrl;
    }

}
